package cn.ffcs.uec.staff.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.staff.dao.UecAbroadDao;
import cn.ffcs.uec.staff.model.UecAbroad;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecAbroadDao")
@Transactional
public class UecAbroadDaoImpl extends BaseDaoImpl implements UecAbroadDao {

	@Override
	public PageInfo queryPageInfoByUecAbroad(UecAbroad uecAbroad, int current,
			int pageSize) {
		if (null != uecAbroad) {
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM UEC_ABROAD T WHERE 1 = 1 ");
			List<Object> params = new ArrayList<Object>();
			sb.append(" AND T.STATUS_CD = ? ");
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);

			if (!StrUtil.isNullOrEmpty(uecAbroad.getPkPsndoc())) {//判断数据是否是集团的
				sb.append(" AND T.PK_PSNDOC = ? ");
				params.add(uecAbroad.getPkPsndoc());
			} else if (!StrUtil.isNullOrEmpty(uecAbroad.getStaffId())) {
				sb.append(" AND T.STAFF_ID = ? ");
				params.add(uecAbroad.getStaffId());
			}
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecAbroad.class);
		}
		return null;
	}
}
